package com.zjc.yohoshop.mvp.view.adapter;

import android.support.annotation.NonNull;
import android.support.v4.view.PagerAdapter;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.zjc.yohoshop.R;
import com.zjc.yohoshop.bean.GoodsValuesEntity;
import com.zjc.yohoshop.network.API;

import java.util.ArrayList;
import java.util.List;

/**
 * 供应页面顶部轮播
 */
public class GoodsValuesHeadSCViewPagerAdapter extends PagerAdapter {

    private List<View> list = new ArrayList<>();

    public GoodsValuesHeadSCViewPagerAdapter(List<View> list) {
        this.list = list;
    }

    @Override
    public int getCount() {
        if (list == null || list.size() == 0){
            return 0;
        }
        return list.size();
    }

    @Override
    public boolean isViewFromObject(@NonNull View view, @NonNull Object o) {
        return view == o;
    }

    @NonNull
    @Override
    public Object instantiateItem(@NonNull ViewGroup container, int position) {
        View view = list.get(position);
        container.addView(view);
        return view;
    }

    @Override
    public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
        View view = (View) object;
        container.removeView(view);
    }
}
